#!/usr/bin/env python
# -*- coding: utf-8 -*- 

#
# Generated Thu May  3 08:30:32 2012 by generateDS.py version 2.7b.
#

import sys
import getopt
import re as re_

etree_ = None
Verbose_import_ = False
(   XMLParser_import_none, XMLParser_import_lxml,
    XMLParser_import_elementtree
    ) = range(3)
XMLParser_import_library = None
try:
    # lxml
    from lxml import etree as etree_
    XMLParser_import_library = XMLParser_import_lxml
    if Verbose_import_:
        print("running with lxml.etree")
except ImportError:
    try:
        # cElementTree from Python 2.5+
        import xml.etree.cElementTree as etree_
        XMLParser_import_library = XMLParser_import_elementtree
        if Verbose_import_:
            print("running with cElementTree on Python 2.5+")
    except ImportError:
        try:
            # ElementTree from Python 2.5+
            import xml.etree.ElementTree as etree_
            XMLParser_import_library = XMLParser_import_elementtree
            if Verbose_import_:
                print("running with ElementTree on Python 2.5+")
        except ImportError:
            try:
                # normal cElementTree install
                import cElementTree as etree_
                XMLParser_import_library = XMLParser_import_elementtree
                if Verbose_import_:
                    print("running with cElementTree")
            except ImportError:
                try:
                    # normal ElementTree install
                    import elementtree.ElementTree as etree_
                    XMLParser_import_library = XMLParser_import_elementtree
                    if Verbose_import_:
                        print("running with ElementTree")
                except ImportError:
                    raise ImportError("Failed to import ElementTree from any known place")

def parsexml_(*args, **kwargs):
    if (XMLParser_import_library == XMLParser_import_lxml and
        'parser' not in kwargs):
        # Use the lxml ElementTree compatible parser so that, e.g.,
        #   we ignore comments.
        kwargs['parser'] = etree_.ETCompatXMLParser()
    doc = etree_.parse(*args, **kwargs)
    return doc

#
# User methods
#
# Calls to the methods in these classes are generated by generateDS.py.
# You can replace these methods by re-implementing the following class
#   in a module named generatedssuper.py.

try:
    from generatedssuper import GeneratedsSuper
except ImportError, exp:

    class GeneratedsSuper(object):
        def gds_format_string(self, input_data, input_name=''):
            return input_data
        def gds_validate_string(self, input_data, node, input_name=''):
            return input_data
        def gds_format_integer(self, input_data, input_name=''):
            return '%d' % input_data
        def gds_validate_integer(self, input_data, node, input_name=''):
            return input_data
        def gds_format_integer_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_integer_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    fvalue = float(value)
                except (TypeError, ValueError), exp:
                    raise_parse_error(node, 'Requires sequence of integers')
            return input_data
        def gds_format_float(self, input_data, input_name=''):
            return '%f' % input_data
        def gds_validate_float(self, input_data, node, input_name=''):
            return input_data
        def gds_format_float_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_float_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    fvalue = float(value)
                except (TypeError, ValueError), exp:
                    raise_parse_error(node, 'Requires sequence of floats')
            return input_data
        def gds_format_double(self, input_data, input_name=''):
            return '%e' % input_data
        def gds_validate_double(self, input_data, node, input_name=''):
            return input_data
        def gds_format_double_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_double_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    fvalue = float(value)
                except (TypeError, ValueError), exp:
                    raise_parse_error(node, 'Requires sequence of doubles')
            return input_data
        def gds_format_boolean(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_boolean(self, input_data, node, input_name=''):
            return input_data
        def gds_format_boolean_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_boolean_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                if value not in ('true', '1', 'false', '0', ):
                    raise_parse_error(node, 'Requires sequence of booleans ("true", "1", "false", "0")')
            return input_data
        def gds_str_lower(self, instring):
            return instring.lower()
        def get_path_(self, node):
            path_list = []
            self.get_path_list_(node, path_list)
            path_list.reverse()
            path = '/'.join(path_list)
            return path
        Tag_strip_pattern_ = re_.compile(r'\{.*\}')
        def get_path_list_(self, node, path_list):
            if node is None:
                return
            tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)
            if tag:
                path_list.append(tag)
            self.get_path_list_(node.getparent(), path_list)
        def get_class_obj_(self, node, default_class=None):
            class_obj1 = default_class
            if 'xsi' in node.nsmap:
                classname = node.get('{%s}type' % node.nsmap['xsi'])
                if classname is not None:
                    names = classname.split(':')
                    if len(names) == 2:
                        classname = names[1]
                    class_obj2 = globals().get(classname)
                    if class_obj2 is not None:
                        class_obj1 = class_obj2
            return class_obj1
        def gds_build_any(self, node, type_name=None):
            return None


#
# If you have installed IPython you can uncomment and use the following.
# IPython is available from http://ipython.scipy.org/.
#

## from IPython.Shell import IPShellEmbed
## args = ''
## ipshell = IPShellEmbed(args,
##     banner = 'Dropping into IPython',
##     exit_msg = 'Leaving Interpreter, back to program.')

# Then use the following line where and when you want to drop into the
# IPython shell:
#    ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')

#
# Globals
#

ExternalEncoding = 'ascii'
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')

#
# Support/utility functions.
#

def showIndent(outfile, level):
    for idx in range(level):
        outfile.write('    ')

def quote_xml(inStr):
    if not inStr:
        return ''
    s1 = (isinstance(inStr, basestring) and inStr or
          '%s' % inStr)
    s1 = s1.replace('&', '&amp;')
    s1 = s1.replace('<', '&lt;')
    s1 = s1.replace('>', '&gt;')
    return s1

def quote_attrib(inStr):
    s1 = (isinstance(inStr, basestring) and inStr or
          '%s' % inStr)
    s1 = s1.replace('&', '&amp;')
    s1 = s1.replace('<', '&lt;')
    s1 = s1.replace('>', '&gt;')
    if '"' in s1:
        if "'" in s1:
            s1 = '"%s"' % s1.replace('"', "&quot;")
        else:
            s1 = "'%s'" % s1
    else:
        s1 = '"%s"' % s1
    return s1

def quote_python(inStr):
    s1 = inStr
    if s1.find("'") == -1:
        if s1.find('\n') == -1:
            return "'%s'" % s1
        else:
            return "'''%s'''" % s1
    else:
        if s1.find('"') != -1:
            s1 = s1.replace('"', '\\"')
        if s1.find('\n') == -1:
            return '"%s"' % s1
        else:
            return '"""%s"""' % s1

def get_all_text_(node):
    if node.text is not None:
        text = node.text
    else:
        text = ''
    for child in node:
        if child.tail is not None:
            text += child.tail
    return text

def find_attr_value_(attr_name, node):
    attrs = node.attrib
    attr_parts = attr_name.split(':')
    value = None
    if len(attr_parts) == 1:
        value = attrs.get(attr_name)
    elif len(attr_parts) == 2:
        prefix, name = attr_parts
        namespace = node.nsmap.get(prefix)
        if namespace is not None:
            value = attrs.get('{%s}%s' % (namespace, name, ))
    return value


class GDSParseError(Exception):
    pass

def raise_parse_error(node, msg):
    if XMLParser_import_library == XMLParser_import_lxml:
        msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )
    else:
        msg = '%s (element %s)' % (msg, node.tag, )
    raise GDSParseError(msg)


class MixedContainer:
    # Constants for category:
    CategoryNone = 0
    CategoryText = 1
    CategorySimple = 2
    CategoryComplex = 3
    # Constants for content_type:
    TypeNone = 0
    TypeText = 1
    TypeString = 2
    TypeInteger = 3
    TypeFloat = 4
    TypeDecimal = 5
    TypeDouble = 6
    TypeBoolean = 7
    def __init__(self, category, content_type, name, value):
        self.category = category
        self.content_type = content_type
        self.name = name
        self.value = value
    def getCategory(self):
        return self.category
    def getContenttype(self, content_type):
        return self.content_type
    def getValue(self):
        return self.value
    def getName(self):
        return self.name
    def export(self, outfile, level, name, namespace):
        if self.category == MixedContainer.CategoryText:
            # Prevent exporting empty content as empty lines.
            if self.value.strip(): 
                outfile.write(self.value)
        elif self.category == MixedContainer.CategorySimple:
            self.exportSimple(outfile, level, name)
        else:    # category == MixedContainer.CategoryComplex
            self.value.export(outfile, level, namespace,name)
    def exportSimple(self, outfile, level, name):
        if self.content_type == MixedContainer.TypeString:
            outfile.write('<%s>%s</%s>' % (self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeInteger or \
                self.content_type == MixedContainer.TypeBoolean:
            outfile.write('<%s>%d</%s>' % (self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeFloat or \
                self.content_type == MixedContainer.TypeDecimal:
            outfile.write('<%s>%f</%s>' % (self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeDouble:
            outfile.write('<%s>%g</%s>' % (self.name, self.value, self.name))
    def exportLiteral(self, outfile, level, name):
        if self.category == MixedContainer.CategoryText:
            showIndent(outfile, level)
            outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \
                (self.category, self.content_type, self.name, self.value))
        elif self.category == MixedContainer.CategorySimple:
            showIndent(outfile, level)
            outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \
                (self.category, self.content_type, self.name, self.value))
        else:    # category == MixedContainer.CategoryComplex
            showIndent(outfile, level)
            outfile.write('model_.MixedContainer(%d, %d, "%s",\n' % \
                (self.category, self.content_type, self.name,))
            self.value.exportLiteral(outfile, level + 1)
            showIndent(outfile, level)
            outfile.write(')\n')


class MemberSpec_(object):
    def __init__(self, name='', data_type='', container=0):
        self.name = name
        self.data_type = data_type
        self.container = container
    def set_name(self, name): self.name = name
    def get_name(self): return self.name
    def set_data_type(self, data_type): self.data_type = data_type
    def get_data_type_chain(self): return self.data_type
    def get_data_type(self):
        if isinstance(self.data_type, list):
            if len(self.data_type) > 0:
                return self.data_type[-1]
            else:
                return 'xs:string'
        else:
            return self.data_type
    def set_container(self, container): self.container = container
    def get_container(self): return self.container

def _cast(typ, value):
    if typ is None or value is None:
        return value
    return typ(value)

#
# Data representation classes.
#

class varioSettings(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, COMPort='55', ComponentID='1', SystemID=None, Baud=None, Timeout=None, MasterID=None, Volume=None, Deadband=None, Offset=None, maxFallRate=None, maxRiseRate=None, minFallingKey=None, maxFallingKey=None, minRisingKey=None, maxRisingKey=None, risingSoundfont=None, fallingSoundfont=None, pulseRate=None, pulseDuty=None):
        self.COMPort = COMPort
        self.ComponentID = ComponentID
        self.SystemID = SystemID
        self.Baud = Baud
        self.Timeout = Timeout
        self.MasterID = MasterID
        self.Volume = Volume
        self.Deadband = Deadband
        self.Offset = Offset
        self.maxFallRate = maxFallRate
        self.maxRiseRate = maxRiseRate
        self.minFallingKey = minFallingKey
        self.maxFallingKey = maxFallingKey
        self.minRisingKey = minRisingKey
        self.maxRisingKey = maxRisingKey
        self.risingSoundfont = risingSoundfont
        self.fallingSoundfont = fallingSoundfont
        self.pulseRate = pulseRate
        self.pulseDuty = pulseDuty
    def factory(*args_, **kwargs_):
        if varioSettings.subclass:
            return varioSettings.subclass(*args_, **kwargs_)
        else:
            return varioSettings(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_COMPort(self): return self.COMPort
    def set_COMPort(self, COMPort): self.COMPort = COMPort
    def get_ComponentID(self): return self.ComponentID
    def set_ComponentID(self, ComponentID): self.ComponentID = ComponentID
    def get_SystemID(self): return self.SystemID
    def set_SystemID(self, SystemID): self.SystemID = SystemID
    def get_Baud(self): return self.Baud
    def set_Baud(self, Baud): self.Baud = Baud
    def get_Timeout(self): return self.Timeout
    def set_Timeout(self, Timeout): self.Timeout = Timeout
    def get_MasterID(self): return self.MasterID
    def set_MasterID(self, MasterID): self.MasterID = MasterID
    def get_Volume(self): return self.Volume
    def set_Volume(self, Volume): self.Volume = Volume
    def get_Deadband(self): return self.Deadband
    def set_Deadband(self, Deadband): self.Deadband = Deadband
    def get_Offset(self): return self.Offset
    def set_Offset(self, Offset): self.Offset = Offset
    def get_maxFallRate(self): return self.maxFallRate
    def set_maxFallRate(self, maxFallRate): self.maxFallRate = maxFallRate
    def get_maxRiseRate(self): return self.maxRiseRate
    def set_maxRiseRate(self, maxRiseRate): self.maxRiseRate = maxRiseRate
    def get_minFallingKey(self): return self.minFallingKey
    def set_minFallingKey(self, minFallingKey): self.minFallingKey = minFallingKey
    def get_maxFallingKey(self): return self.maxFallingKey
    def set_maxFallingKey(self, maxFallingKey): self.maxFallingKey = maxFallingKey
    def get_minRisingKey(self): return self.minRisingKey
    def set_minRisingKey(self, minRisingKey): self.minRisingKey = minRisingKey
    def get_maxRisingKey(self): return self.maxRisingKey
    def set_maxRisingKey(self, maxRisingKey): self.maxRisingKey = maxRisingKey
    def get_risingSoundfont(self): return self.risingSoundfont
    def set_risingSoundfont(self, risingSoundfont): self.risingSoundfont = risingSoundfont
    def get_fallingSoundfont(self): return self.fallingSoundfont
    def set_fallingSoundfont(self, fallingSoundfont): self.fallingSoundfont = fallingSoundfont
    def get_pulseRate(self): return self.pulseRate
    def set_pulseRate(self, pulseRate): self.pulseRate = pulseRate
    def get_pulseDuty(self): return self.pulseDuty
    def set_pulseDuty(self, pulseDuty): self.pulseDuty = pulseDuty
    def export(self, outfile, level, namespace_='', name_='varioSettings', namespacedef_=''):
        showIndent(outfile, level)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='varioSettings')
        if self.hasContent_():
            outfile.write('>\n')
            self.exportChildren(outfile, level + 1, namespace_, name_)
            showIndent(outfile, level)
            outfile.write('</%s%s>\n' % (namespace_, name_))
        else:
            outfile.write('/>\n')
    def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='varioSettings'):
        pass
    def exportChildren(self, outfile, level, namespace_='', name_='varioSettings', fromsubclass_=False):
        if self.COMPort is not None:
            showIndent(outfile, level)
            outfile.write('<%sCOMPort>%s</%sCOMPort>\n' % (namespace_, self.gds_format_string(quote_xml(self.COMPort).encode(ExternalEncoding), input_name='COMPort'), namespace_))
        if self.ComponentID is not None:
            showIndent(outfile, level)
            outfile.write('<%sComponentID>%s</%sComponentID>\n' % (namespace_, self.gds_format_string(quote_xml(self.ComponentID).encode(ExternalEncoding), input_name='ComponentID'), namespace_))
        if self.SystemID is not None:
            showIndent(outfile, level)
            outfile.write('<%sSystemID>%s</%sSystemID>\n' % (namespace_, self.gds_format_string(quote_xml(self.SystemID).encode(ExternalEncoding), input_name='SystemID'), namespace_))
        if self.Baud is not None:
            showIndent(outfile, level)
            outfile.write('<%sBaud>%s</%sBaud>\n' % (namespace_, self.gds_format_string(quote_xml(self.Baud).encode(ExternalEncoding), input_name='Baud'), namespace_))
        if self.Timeout is not None:
            showIndent(outfile, level)
            outfile.write('<%sTimeout>%s</%sTimeout>\n' % (namespace_, self.gds_format_float(self.Timeout, input_name='Timeout'), namespace_))
        if self.MasterID is not None:
            showIndent(outfile, level)
            outfile.write('<%sMasterID>%s</%sMasterID>\n' % (namespace_, self.gds_format_string(quote_xml(self.MasterID).encode(ExternalEncoding), input_name='MasterID'), namespace_))
        if self.Volume is not None:
            showIndent(outfile, level)
            outfile.write('<%sVolume>%s</%sVolume>\n' % (namespace_, self.gds_format_float(self.Volume, input_name='Volume'), namespace_))
        if self.Deadband is not None:
            showIndent(outfile, level)
            outfile.write('<%sDeadband>%s</%sDeadband>\n' % (namespace_, self.gds_format_float(self.Deadband, input_name='Deadband'), namespace_))
        if self.Offset is not None:
            showIndent(outfile, level)
            outfile.write('<%sOffset>%s</%sOffset>\n' % (namespace_, self.gds_format_float(self.Offset, input_name='Offset'), namespace_))
        if self.maxFallRate is not None:
            showIndent(outfile, level)
            outfile.write('<%smaxFallRate>%s</%smaxFallRate>\n' % (namespace_, self.gds_format_float(self.maxFallRate, input_name='maxFallRate'), namespace_))
        if self.maxRiseRate is not None:
            showIndent(outfile, level)
            outfile.write('<%smaxRiseRate>%s</%smaxRiseRate>\n' % (namespace_, self.gds_format_float(self.maxRiseRate, input_name='maxRiseRate'), namespace_))
        if self.minFallingKey is not None:
            showIndent(outfile, level)
            outfile.write('<%sminFallingKey>%s</%sminFallingKey>\n' % (namespace_, self.gds_format_integer(self.minFallingKey, input_name='minFallingKey'), namespace_))
        if self.maxFallingKey is not None:
            showIndent(outfile, level)
            outfile.write('<%smaxFallingKey>%s</%smaxFallingKey>\n' % (namespace_, self.gds_format_integer(self.maxFallingKey, input_name='maxFallingKey'), namespace_))
        if self.minRisingKey is not None:
            showIndent(outfile, level)
            outfile.write('<%sminRisingKey>%s</%sminRisingKey>\n' % (namespace_, self.gds_format_integer(self.minRisingKey, input_name='minRisingKey'), namespace_))
        if self.maxRisingKey is not None:
            showIndent(outfile, level)
            outfile.write('<%smaxRisingKey>%s</%smaxRisingKey>\n' % (namespace_, self.gds_format_integer(self.maxRisingKey, input_name='maxRisingKey'), namespace_))
        if self.risingSoundfont is not None:
            showIndent(outfile, level)
            outfile.write('<%srisingSoundfont>%s</%srisingSoundfont>\n' % (namespace_, self.gds_format_string(quote_xml(self.risingSoundfont).encode(ExternalEncoding), input_name='risingSoundfont'), namespace_))
        if self.fallingSoundfont is not None:
            showIndent(outfile, level)
            outfile.write('<%sfallingSoundfont>%s</%sfallingSoundfont>\n' % (namespace_, self.gds_format_string(quote_xml(self.fallingSoundfont).encode(ExternalEncoding), input_name='fallingSoundfont'), namespace_))
        if self.pulseRate is not None:
            showIndent(outfile, level)
            outfile.write('<%spulseRate>%s</%spulseRate>\n' % (namespace_, self.gds_format_float(self.pulseRate, input_name='pulseRate'), namespace_))
        if self.pulseDuty is not None:
            showIndent(outfile, level)
            outfile.write('<%spulseDuty>%s</%spulseDuty>\n' % (namespace_, self.gds_format_integer(self.pulseDuty, input_name='pulseDuty'), namespace_))
    def hasContent_(self):
        if (
            self.COMPort is not None or
            self.ComponentID is not None or
            self.SystemID is not None or
            self.Baud is not None or
            self.Timeout is not None or
            self.MasterID is not None or
            self.Volume is not None or
            self.Deadband is not None or
            self.Offset is not None or
            self.maxFallRate is not None or
            self.maxRiseRate is not None or
            self.minFallingKey is not None or
            self.maxFallingKey is not None or
            self.minRisingKey is not None or
            self.maxRisingKey is not None or
            self.risingSoundfont is not None or
            self.fallingSoundfont is not None or
            self.pulseRate is not None or
            self.pulseDuty is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='varioSettings'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        if self.COMPort is not None:
            showIndent(outfile, level)
            outfile.write('COMPort=%s,\n' % quote_python(self.COMPort).encode(ExternalEncoding))
        if self.ComponentID is not None:
            showIndent(outfile, level)
            outfile.write('ComponentID=%s,\n' % quote_python(self.ComponentID).encode(ExternalEncoding))
        if self.SystemID is not None:
            showIndent(outfile, level)
            outfile.write('SystemID=%s,\n' % quote_python(self.SystemID).encode(ExternalEncoding))
        if self.Baud is not None:
            showIndent(outfile, level)
            outfile.write('Baud=%s,\n' % quote_python(self.Baud).encode(ExternalEncoding))
        if self.Timeout is not None:
            showIndent(outfile, level)
            outfile.write('Timeout=%f,\n' % self.Timeout)
        if self.MasterID is not None:
            showIndent(outfile, level)
            outfile.write('MasterID=%s,\n' % quote_python(self.MasterID).encode(ExternalEncoding))
        if self.Volume is not None:
            showIndent(outfile, level)
            outfile.write('Volume=%f,\n' % self.Volume)
        if self.Deadband is not None:
            showIndent(outfile, level)
            outfile.write('Deadband=%f,\n' % self.Deadband)
        if self.Offset is not None:
            showIndent(outfile, level)
            outfile.write('Offset=%f,\n' % self.Offset)
        if self.maxFallRate is not None:
            showIndent(outfile, level)
            outfile.write('maxFallRate=%f,\n' % self.maxFallRate)
        if self.maxRiseRate is not None:
            showIndent(outfile, level)
            outfile.write('maxRiseRate=%f,\n' % self.maxRiseRate)
        if self.minFallingKey is not None:
            showIndent(outfile, level)
            outfile.write('minFallingKey=%d,\n' % self.minFallingKey)
        if self.maxFallingKey is not None:
            showIndent(outfile, level)
            outfile.write('maxFallingKey=%d,\n' % self.maxFallingKey)
        if self.minRisingKey is not None:
            showIndent(outfile, level)
            outfile.write('minRisingKey=%d,\n' % self.minRisingKey)
        if self.maxRisingKey is not None:
            showIndent(outfile, level)
            outfile.write('maxRisingKey=%d,\n' % self.maxRisingKey)
        if self.risingSoundfont is not None:
            showIndent(outfile, level)
            outfile.write('risingSoundfont=%s,\n' % quote_python(self.risingSoundfont).encode(ExternalEncoding))
        if self.fallingSoundfont is not None:
            showIndent(outfile, level)
            outfile.write('fallingSoundfont=%s,\n' % quote_python(self.fallingSoundfont).encode(ExternalEncoding))
        if self.pulseRate is not None:
            showIndent(outfile, level)
            outfile.write('pulseRate=%f,\n' % self.pulseRate)
        if self.pulseDuty is not None:
            showIndent(outfile, level)
            outfile.write('pulseDuty=%d,\n' % self.pulseDuty)
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'COMPort':
            COMPort_ = child_.text
            COMPort_ = self.gds_validate_string(COMPort_, node, 'COMPort')
            self.COMPort = COMPort_
        elif nodeName_ == 'ComponentID':
            ComponentID_ = child_.text
            ComponentID_ = self.gds_validate_string(ComponentID_, node, 'ComponentID')
            self.ComponentID = ComponentID_
        elif nodeName_ == 'SystemID':
            SystemID_ = child_.text
            SystemID_ = self.gds_validate_string(SystemID_, node, 'SystemID')
            self.SystemID = SystemID_
        elif nodeName_ == 'Baud':
            Baud_ = child_.text
            Baud_ = self.gds_validate_string(Baud_, node, 'Baud')
            self.Baud = Baud_
        elif nodeName_ == 'Timeout':
            sval_ = child_.text
            try:
                fval_ = float(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires float or double: %s' % exp)
            fval_ = self.gds_validate_float(fval_, node, 'Timeout')
            self.Timeout = fval_
        elif nodeName_ == 'MasterID':
            MasterID_ = child_.text
            MasterID_ = self.gds_validate_string(MasterID_, node, 'MasterID')
            self.MasterID = MasterID_
        elif nodeName_ == 'Volume':
            sval_ = child_.text
            try:
                fval_ = float(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires float or double: %s' % exp)
            fval_ = self.gds_validate_float(fval_, node, 'Volume')
            self.Volume = fval_
        elif nodeName_ == 'Deadband':
            sval_ = child_.text
            try:
                fval_ = float(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires float or double: %s' % exp)
            fval_ = self.gds_validate_float(fval_, node, 'Deadband')
            self.Deadband = fval_
        elif nodeName_ == 'Offset':
            sval_ = child_.text
            try:
                fval_ = float(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires float or double: %s' % exp)
            fval_ = self.gds_validate_float(fval_, node, 'Offset')
            self.Offset = fval_
        elif nodeName_ == 'maxFallRate':
            sval_ = child_.text
            try:
                fval_ = float(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires float or double: %s' % exp)
            fval_ = self.gds_validate_float(fval_, node, 'maxFallRate')
            self.maxFallRate = fval_
        elif nodeName_ == 'maxRiseRate':
            sval_ = child_.text
            try:
                fval_ = float(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires float or double: %s' % exp)
            fval_ = self.gds_validate_float(fval_, node, 'maxRiseRate')
            self.maxRiseRate = fval_
        elif nodeName_ == 'minFallingKey':
            sval_ = child_.text
            try:
                ival_ = int(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires integer: %s' % exp)
            ival_ = self.gds_validate_integer(ival_, node, 'minFallingKey')
            self.minFallingKey = ival_
        elif nodeName_ == 'maxFallingKey':
            sval_ = child_.text
            try:
                ival_ = int(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires integer: %s' % exp)
            ival_ = self.gds_validate_integer(ival_, node, 'maxFallingKey')
            self.maxFallingKey = ival_
        elif nodeName_ == 'minRisingKey':
            sval_ = child_.text
            try:
                ival_ = int(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires integer: %s' % exp)
            ival_ = self.gds_validate_integer(ival_, node, 'minRisingKey')
            self.minRisingKey = ival_
        elif nodeName_ == 'maxRisingKey':
            sval_ = child_.text
            try:
                ival_ = int(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires integer: %s' % exp)
            ival_ = self.gds_validate_integer(ival_, node, 'maxRisingKey')
            self.maxRisingKey = ival_
        elif nodeName_ == 'risingSoundfont':
            risingSoundfont_ = child_.text
            risingSoundfont_ = self.gds_validate_string(risingSoundfont_, node, 'risingSoundfont')
            self.risingSoundfont = risingSoundfont_
        elif nodeName_ == 'fallingSoundfont':
            fallingSoundfont_ = child_.text
            fallingSoundfont_ = self.gds_validate_string(fallingSoundfont_, node, 'fallingSoundfont')
            self.fallingSoundfont = fallingSoundfont_
        elif nodeName_ == 'pulseRate':
            sval_ = child_.text
            try:
                fval_ = float(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires float or double: %s' % exp)
            fval_ = self.gds_validate_float(fval_, node, 'pulseRate')
            self.pulseRate = fval_
        elif nodeName_ == 'pulseDuty':
            sval_ = child_.text
            try:
                ival_ = int(sval_)
            except (TypeError, ValueError), exp:
                raise_parse_error(child_, 'requires integer: %s' % exp)
            ival_ = self.gds_validate_integer(ival_, node, 'pulseDuty')
            self.pulseDuty = ival_
# end class varioSettings


USAGE_TEXT = """
Usage: python <Parser>.py [ -s ] <in_xml_file>
"""

def usage():
    print USAGE_TEXT
    sys.exit(1)


def get_root_tag(node):
    tag = Tag_pattern_.match(node.tag).groups()[-1]
    rootClass = globals().get(tag)
    return tag, rootClass


def parse(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'varioSettings'
        rootClass = varioSettings
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('<?xml version="1.0" ?>\n')
##     rootObj.export(sys.stdout, 0, name_=rootTag, 
##         namespacedef_='')
    return rootObj


def parseString(inString):
    from StringIO import StringIO
    doc = parsexml_(StringIO(inString))
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'varioSettings'
        rootClass = varioSettings
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('<?xml version="1.0" ?>\n')
##     rootObj.export(sys.stdout, 0, name_="varioSettings",
##         namespacedef_='')
    return rootObj


def parseLiteral(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'varioSettings'
        rootClass = varioSettings
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('#from varioSettings import *\n\n')
##     sys.stdout.write('import varioSettings as model_\n\n')
##     sys.stdout.write('rootObj = model_.rootTag(\n')
##     rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
##     sys.stdout.write(')\n')
    return rootObj


def main():
    args = sys.argv[1:]
    if len(args) == 1:
        parse(args[0])
    else:
        usage()


if __name__ == '__main__':
    #import pdb; pdb.set_trace()
    main()


__all__ = [
    "varioSettings"
    ]
